package com.briup.web;

import com.briup.pojo.Customer;

import javax.servlet.*;
import javax.servlet.http.HttpServletRequest;
import java.io.IOException;

public class LoginFilter implements Filter {
    public void destroy() {
    }

    public void doFilter(ServletRequest req, ServletResponse resp, FilterChain chain) throws ServletException, IOException {
        HttpServletRequest httpServletRequest = (HttpServletRequest) req;
        Customer customer = (Customer) httpServletRequest.getSession().getAttribute("login");
        if (customer ==null){
         httpServletRequest.getRequestDispatcher("/login.jsp").forward(req,resp);
    } else {
      chain.doFilter(req, resp);
        }

    }

    public void init(FilterConfig config) throws ServletException {

    }

}
